package com.huawei.appgallery.agwebview.delegate;

import android.content.Context;
import android.view.View;
import com.huawei.appgallery.agwebview.api.ui.IAppDetailWebViewFragmentProtocol;
import com.huawei.appgallery.agwebview.api.ui.IWebViewActivityProtocol;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSStyleSheet;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import java.util.HashMap;
import java.util.Map;
import o.azf;
import o.azh;
import o.bab;
import o.bax;
import o.bax.c;
import o.Logger;
import o.dnk;
import o.dof;

public class AppDetailFragmentWebViewDelegate extends FragmentWebViewDelegate implements c {
    private String ʾ;
    private int ˈ;
    private String ˉ;
    private String ˊˊ;
    private String ˊˋ;

    public void ॱ(Context context, IWebViewActivityProtocol iWebViewActivityProtocol) {
        if (iWebViewActivityProtocol instanceof IAppDetailWebViewFragmentProtocol) {
            IAppDetailWebViewFragmentProtocol iAppDetailWebViewFragmentProtocol = (IAppDetailWebViewFragmentProtocol) iWebViewActivityProtocol;
            this.ʾ = iAppDetailWebViewFragmentProtocol.getCss();
            this.ˈ = iAppDetailWebViewFragmentProtocol.getStyle();
            this.ˊˋ = iAppDetailWebViewFragmentProtocol.getCssSelector();
            this.ˉ = iAppDetailWebViewFragmentProtocol.getAppId();
            this.ˊˊ = iAppDetailWebViewFragmentProtocol.getPackageName();
        }
        super.ॱ(context, this.ॱॱ);
    }

    public void ˋ() {
        super.ˋ();
        if (this.ˈ == 1) {
            this.ʼ.setBackgroundColor(this.ˊ.getResources().getColor(azf.c.ˊ));
            ˋ(this.ᐝ);
        }
    }

    private Map<String, String> ˋᐝ() {
        Map<String, String> hashMap = new HashMap();
        hashMap.put("packageName", this.ˊˊ);
        hashMap.put("appId", this.ˉ);
        try {
            if (this.ˈ != 1 || dof.ॱ(this.ʾ)) {
                if (Logger.ˎ()) {
                    azh.ˏ.ˋ("AppDetailFragmentWebViewDelegate", "createPostData no immer data");
                }
                return hashMap;
            }
            hashMap.put("color_conf", dnk.ˏ(this.ʾ.getBytes("UTF-8")));
            return hashMap;
        } catch (Throwable e) {
            azh.ˏ.ˊ("AppDetailFragmentWebViewDelegate", "createPostData error", e);
        }
    }

    private void ˋ(View view) {
        if (this.ʾ != null && this.ˊˋ != null && view != null) {
            CSSSelector cSSSelector = new CSSSelector(this.ˊˋ);
            CSSStyleSheet parse = CSSStyleSheet.parse(this.ʾ);
            if (parse != null) {
                CSSRule rule = cSSSelector.getRule(parse.getRootRule());
                if (rule != null) {
                    CSSView.wrap(view, rule).render();
                }
            }
        }
    }

    public String ॱॱ() {
        if (this.ʼॱ != null) {
            return this.ʼॱ.ˊ();
        }
        return super.ॱॱ();
    }

    public String ʾ() {
        return "AppDetailFragmentWebViewDelegate";
    }

    public bab ˋˊ() {
        bab o_bax = new bax();
        o_bax.ॱ(this);
        return o_bax;
    }

    public Map<String, String> ˎˎ() {
        return ˋᐝ();
    }
}
